#pragma once

#include <D3D11.h>
#include <D3DX10math.h>
#include "textureclass.h"

/// <Summary>
/// BitmapClass: Encapsulates a bitmap by storing its vertex and index buffer, index
/// count, and texture object.
/// <\Summary>
class BitmapClass
{
private:
	struct VertexType2D	// Same format as in TextureShaderClass.
	{
		D3DXVECTOR3 position;
		D3DXVECTOR2 texture;
	};

public:
	BitmapClass();
	BitmapClass(const BitmapClass&);
	~BitmapClass();

	bool Initialize(ID3D11Device* device, int screenWidth, int screenHeight, 
		WCHAR* textureFilename, int bitmapWidth, int bitmapHeight);
	void Shutdown();
	bool Render(ID3D11DeviceContext* deviceContext);

	bool UpdateBuffers(ID3D11DeviceContext* deviceContext, int positionX, int positionY);

	int GetIndexCount();
	ID3D11ShaderResourceView* GetTexture();

private:
	bool InitializeBuffers(ID3D11Device*);
	void ShutdownBuffers();
	void RenderBuffers(ID3D11DeviceContext*);

	bool LoadTexture(ID3D11Device*, WCHAR*);
	void ReleaseTexture();

private:
	ID3D11Buffer	  *m_vertexBuffer, *m_indexBuffer;
	int m_vertexCount, m_indexCount;
	TextureClass*	   m_Texture;

	// Needs to maintain screen size, bitmap size, and previous rendered position.
	int m_screenWidth,  m_screenHeight;
	int m_bitmapWidth,  m_bitmapHeight;
	int m_previousPosX, m_previousPosY;
};